/** 项目构建入口 */
import Vue from 'vue'
import VueRouter from 'vue-router'
import Vuex from 'vuex'
import App from './App.vue'
import createRouter from '../config/router'
import createStore from './store/store'
import './assets/styles/global.scss'

import Notification from './components/notification'
import Tabs from './components/tabs'

Vue.use(VueRouter)
Vue.use(Vuex)

Vue.use(Notification)
Vue.use(Tabs)

const router = createRouter()
const store = createStore()

// 全局导航守卫
router.beforeEach((to, from, next) => {
  console.log('before each invoked', this)
  next()
  // if (to.fullPath === '/') {
  //   next('/login')
  // } else {
  //   next()
  // }
})
router.beforeResolve((to, from, next) => {
  console.log('before resolve invoked')
  next()
})
router.afterEach((to, from) => {
  console.log('after each invoked')
})

const root = document.createElement('div')
document.body.appendChild(root)

new Vue({
  router,
  store,
  render: (h) => h(App)
}).$mount(root)
